<!doctype html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml" xmlns:v-on="http://www.w3.org/1999/xhtml" xmlns:v-model="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>

<div id="app">
    <p>Total:{{total}}</p>
    <div>父组件处理了子组件的事件（父组件的数据会更新）：<my-component v-on:add="addTotal"></my-component></div>
    <div>父组件处理了子组件的事件（父组件的数据会更新）：<my-component @add="addTotal"></my-component></div>
    <div>父组件未处理子组件的事件（父组件的数据不会更新）：<my-component></my-component></div>
</div>


</body>
<script src="../../../vender/vue@2.4.2.js"></script>
<script>
    var myComponent={
        template:'<button @click="addCounter">{{counter}}</button>',
        data: function () {
            return {
                counter:0
            }
        },
        methods:{
            addCounter: function () {
                this.counter++;
                this.$emit('add');
            }
        }
    };

    var app=new Vue({
        el:'#app',
        components:{
            'my-component':myComponent
        },
        data:{
            total:0
        },
        methods:{
            addTotal: function () {
                this.total++;
            }
        }
    });


</script>
</html>